package service.auth.impl;

import java.util.List;
import java.util.Map;

import model.auth.Roles;
import model.auth.Users;
import model.auth.UsersRoles;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import core.base.page.Page;
import core.base.page.PageRequest;

import service.auth.UsersRolesService;
import dao.auth.UsersRolesDao;

@Service("auth.UsersRolesService")
public class UsersRolesServiceImpl implements UsersRolesService {

	@Autowired
	@Qualifier("auth.UsersRolesDao")
	private UsersRolesDao usersRolesDao;

	public int deleteById(Long id) {
		return usersRolesDao.deleteById(id);
	}

	public UsersRoles getById(Long id) {
		return usersRolesDao.getById(id);
	}

	public void insert(UsersRoles model) {
		usersRolesDao.insert(model);
	}

	public List<Roles> getRolesByUserId(Long userId) {
		return usersRolesDao.getRolesByUserId(userId);
	}

	public List<Users> getUsersByRoleId(Long roleId) {
		return usersRolesDao.getUsersByRoleId(roleId);
	}

	public Page<Roles> queryRolesForPage(PageRequest<Map> pageReq) {
		Page<Roles> page = usersRolesDao.queryRolesForPage(pageReq);
		return page;
	}

	public Page<Users> queryUsersForPage(PageRequest<Map> pageReq) {
		Page<Users> page = usersRolesDao.queryUsersForPage(pageReq);
		return page;
	}

	public void setUsersRolesDao(UsersRolesDao usersRolesDao) {
		this.usersRolesDao = usersRolesDao;
	}

}
